package db

import "time"

//用户表
type Admin struct {
	UserId    int64  `gorm:"column:user_id;AUTO_INCREMENT;primary_key"`
	User      string `gorm:"column:user;type:varchar(40);comment:用户账号"`
	Pass      string `gorm:"column:pass;type:varchar(40);comment:用户密码"`
	CreatedAt time.Time
	UpdatedAt time.Time
}

////角色表
//type UserRole struct {
//   RoleId 	int64  `gorm:"column:role_id;AUTO_INCREMENT;primary_key;comment:角色id"`
//   RoleName     string `gorm:"column:role_name;type:varchar(10);comment:角色名称"`
//   Description  string `gorm:"column:description;type:varchar(100);comment:角色描述"`
//   CreatedAt time.Time
//   UpdatedAt time.Time
//}
//
////权限表
//type Permisson struct {
//	PermissonId int64  `gorm:"column:permisson_id;AUTO_INCREMENT;primary_key;comment:权限id"`
//	PermissonName string `gorm:"column:permisson_name;type:varchar(10);comment:权限名称"`
//	Url string `gorm:"column:url;type:varchar(40);comment:路径"`
//	Status   int `gorm:"column:status;type:int;comment:状态(0:禁止,1:正常)"`
//	CreatedAt time.Time
//	UpdatedAt time.Time
//}
//
////用户角色关联表
//type AdminUserRole struct {
//    UserRoleId int64  `gorm:"column:user_role_id;AUTO_INCREMENT;primary_key;comment:用户角色id"`
//	UserId int64 `gorm:"column:user_id;comment:用户id"`
//	RoleId 	int64  `gorm:"column:role_id;comment:角色id"`
//	CreatedAt time.Time
//	UpdatedAt time.Time
//}
//
////角色权限关联表
//type RolePermisson struct {
//	RolePermissionID int64 `gorm:"column:role_permisson_id;AUTO_INCREMENT;primary_key;comment:角色权限id"`
//	RoleId 	int64  `gorm:"column:role_id;comment:角色id"`
//	PermissonId int64  `gorm:"column:permisson_id;comment:权限id"`
//	CreatedAt time.Time
//	UpdatedAt time.Time
//}

type Node struct {
	NodeId    string `gorm:"column:node_id;type:varchar(255);primary_key"`
	NodeName  string `gorm:"column:node_name;type:varchar(100)"`
	Remark    string `gorm:"column:remark;type:varchar(255)"`
	CreatedAt time.Time
	UpdatedAt time.Time
}

type HeartBeat struct {
	StoreId   string `gorm:"column:store_id;type:varchar(255);primary_key"`
	CreatedAt time.Time
	UpdatedAt time.Time
}

type SystemInfo struct {
	StoreId        string  `gorm:"column:store_id;type:varchar(255);primary_key"`
	CpuPercent     float64 `gorm:"column:cpu_percent;comment:cpu使用率"`
	CpuCount       int     `gorm:"column:cpu_count;comment:cpu物理核心"`
	CpuGhz         float64 `gorm:"column:cpu_ghz;comment:cpu主频"`
	DiskPercent    float64 `gorm:"column:disk_percent;comment:磁盘使用率"`
	DiskTotal      int64   `gorm:"column:disk_total;comment:总磁盘大小"`
	DiskUsed       int64   `gorm:"column:disk_used;comment:磁盘已使用"`
	SwapTotal      int64   `gorm:"column:swap_total;comment:swap大小"`
	SwapUsed       int64   `gorm:"column:swap_used;comment:swap已使用"`
	SwapPercent    float64 `gorm:"column:swap_percent;comment:swap使用率"`
	MemPercent     float64 `gorm:"column:mem_percent;comment:内存使用率"`
	MemTotal       int64   `gorm:"column:mem_total;comment:总内存"`
	MemUsed        int64   `gorm:"column:mem_used;comment:已使用内存"`
	StoreFileCount int64   `gorm:"column:store_file_Count;comment:存储文件数"`
	CreatedAt      time.Time
	UpdatedAt      time.Time
}

type Store struct {
	StoreId   string `gorm:"column:store_id;type:varchar(255);primary_key"`
	StoreIp   string `gorm:"column:store_ip;type:varchar(20)"`
	HttpPort  string `gorm:"column:http_port;type:varchar(40)"`
	TcpPort   string `gorm:"column:tcp_port;type:varchar(40)"`
	NodeId    string `gorm:"column:node_id;type:varchar(255)"`
	Weight    int    `gorm:"column:weight;type:int"`
	CreatedAt time.Time
	UpdatedAt time.Time
}

type SyncTask struct {
	TaskId    int64  `gorm:"column:task_id;AUTO_INCREMENT;primary_key"`
	StoreId   string `gorm:"column:store_id;type:varchar(255);comment:源数据服务ID"`
	StoreIp   string `gorm:"column:store_ip;type:varchar(20);comment:源数据服务IP"`
	TargetIp  string `gorm:"column:target_ip;type:varchar(20);comment:目标IP"`
	TargetId  string `gorm:"column:target_id;type:varchar(255);comment:目标服务ID"`
	DbPort    int    `gorm:"column:db_port;type:int;comment:tcp数据传输端口"`
	NodeId    string `gorm:"column:node_id;type:varchar(255);comment:节点ID"`
	NodeName  string `gorm:"column:node_name;type:varchar(255);comment:节点名称"`
	RecordId  int64  `gorm:"column:Record_id;comment:已完成的记录ID"`
	Percent   int    `gorm:"column:percent;type:int;comment:任务进度百分比"`
	Status    int    `gorm:"column:status;type:int;comment:状态:0-停止 1-运行中 2-完成"`
	CreatedAt time.Time
	UpdatedAt time.Time
}

func (SyncTask) TableName() string {
	return "gdfs_sync_task"
}

//设置表名
func (Admin) TableName() string {
	return "gdfs_admin"
}

func (SystemInfo) TableName() string {
	return "gdfs_sys_info"
}

//func (UserRole) TableName() string {
//	return "gdfs_role"
//}
//
//func (Permisson) TableName() string {
//	return "gdfs_permisson"
//}
//
//func (AdminUserRole) TableName() string {
//	return "gdfs_user_role"
//}
//
//
//func (RolePermisson) TableName() string {
//	return "gdfs_permisson_role"
//}

func (HeartBeat) TableName() string {
	return "gdfs_heartbeat"
}

func (Node) TableName() string {
	return "gdfs_node"
}

func (Store) TableName() string {
	return "gdfs_store"
}
